/imports
/imports/knockout
knockout-3.0.0.js
/typings
knockout.d.ts
headers.ts
io.ts
ko.ts
managed.ts
managed2.ts
pe.html
pe.ts
unmanaged.ts
1
/// <reference path="headers.ts" />
2
/// <reference path="io.ts" />
3
 
4
module pe.unmanaged {
5
 
6
  export class DllExport {
7
    name: string;
8
    ordinal: number;
9
 
10
    // The address of the exported symbol when loaded into memory, relative to the image base.
11
    // For example, the address of an exported function.
12
    exportRva: number;
13
 
14
    // Null-terminated ASCII string in the export section.
15
    // This string must be within the range that is given by the export table data directory entry.
16
    // This string gives the DLL name and the name of the export (for example, "MYDLL.expfunc")
17
    // or the DLL name and the ordinal number of the export (for example, "MYDLL.#27").
18
    forwarder: string;
19
 
20
    static readExports(reader: io.BufferReader, range: io.AddressRange): DllExports {
21
      var result: DllExports = <any>[];
22
 
23
      result.flags = reader.readInt();
24
      if (!result.timestamp)
25
        result.timestamp = new Date(0);
26
 
27
      result.timestamp.setTime(reader.readInt() * 1000);
28
      
29
      var majorVersion = reader.readShort();
30
      var minorVersion = reader.readShort();
31
      result.version = majorVersion + "." + minorVersion;
32
 
33
      // need to read string from that RVA later
34
      var nameRva = reader.readInt();
35
        
36
      result.ordinalBase = reader.readInt();
37
 
38
      // The number of entries in the export address table.
39
      var addressTableEntries = reader.readInt();
40
 
41
      // The number of entries in the name pointer table. This is also the number of entries in the ordinal table.
42
      var numberOfNamePointers = reader.readInt();
43
 
44
      // The address of the export address table, relative to the image base.
45
      var exportAddressTableRva = reader.readInt();
46
 
47
      // The address of the export name pointer table, relative to the image base.
48
      // The table size is given by the Number of Name Pointers field.
49
      var namePointerRva = reader.readInt();
50
 
51
      // The address of the ordinal table, relative to the image base.
52
      var ordinalTableRva = reader.readInt();
53
 
54
      if (nameRva == 0) {
55
        result.dllName = null;
56
      }
57
      else {
58
        var saveOffset = reader.offset;
59
        reader.setVirtualOffset(nameRva);
60
        result.dllName = reader.readAsciiZ();
61
        reader.offset = saveOffset;
62
      }